import { detailApi } from "@/api/detail.js";

const detailModule = {
  namespaced: true,
  state() {
    return {
      // 详情数据
      detailInfo: {},
    };
  },
  mutations: {
    // 同步的改变详情数据的方法
    getDetail(state, payload) {
      state.detailInfo = payload.result;
    },
  },
  actions: {
    // 详情的请求
    async asyncGetDetail({ commit }, payload) {
      const res = await detailApi({ id: payload.id });
      // console.log(res);
      commit("getDetail", res);
    },
  },
};

export default detailModule;
